package com.xiaoq.shop.entity;

import com.xiaoq.MongoEntity;
import com.xiaoq.shop.dto.TagsDTO;
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.utils.IndexDirection;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author xinpeng created on 2016/10/31-下午3:29.
 */

@Entity(value = "shop_member_collection", noClassnameStored = true) //采用Morphia作为mongo client时
public class MemberEntity extends MongoEntity {

    public MemberEntity(){

        lastPurchasedDateTime = new Date(1).getTime();
    }

    private String shopId; //小店id

    private String shopName; //小店名称

    private String shopLogoUrl;  //小店logoUrl

    private Long userId;  //在格调生活365中的用户id,但是当实体店在线下增加会员时,此会员有可能还不是格调生活365的会员,此时userId为空

    private String displayName;  //显示名称

    private String realName;  //真实姓名

    private String displayImgUrl;  //用户头像

    private int gender;  //性别

    private int monthOfBirth;  //出生月

    private int dayOfBirth; //出生日

    private String birthDate; //出生日期

    private String cellphoneNumber;    //手机号

    private String weChatNo;  //微信号

    private String emailAddress;  //邮件地址

    private String address; //住址

    private List<TagsDTO> tags;  //当前小店的店主,对会员标注的标签

    private int evaluationLevel;  //对客户的评价等级: 1,优;2,中;3一般

    private Long lastPurchasedDateTime;  //在当前小店的最后一次购买时间, 定时任务,每天晚上更新一次

    private int totalPurchasedTimes;  //在当前小店的总购买次数, 定时任务,每天晚上更新一次

    private double totalAmountOfConsumption; //在当前小店的总消费金额, 定时任务,每天晚上更新一次


    private String lastLoginedRegId;  //用户最后一次登录APP所用的设备id（小米移动端SDK生成）;

    private String lastLoginedOsType;  //用户最后一次登录APP所用的设备类型

    //以下是会员卡相关属性
    @Indexed(value= IndexDirection.ASC, name="membershipCardNo_index", unique=true, dropDups=true)
    private String membershipCardNo;  //会员卡编号

    private int membershipCardLevel;  //会员卡等级,目前支持4种:1,普卡;2,银卡;3,金卡;4,白金卡;

    private double discount; //折扣

    private String membershipCardCoverImgUrl; //会员卡封面图片url

    private Long scoreInCard;  //卡内积分

    private double balance;  //卡内余额

    @Embedded
    private List<RechargeEntity> recharges = new ArrayList<>();  //充值记录

	public String getShopId() {
		return shopId;
	}

	public void setShopId(String shopId) {
		this.shopId = shopId;
	}

	public String getShopName() {
		return shopName;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}

	public String getShopLogoUrl() {
		return shopLogoUrl;
	}

	public void setShopLogoUrl(String shopLogoUrl) {
		this.shopLogoUrl = shopLogoUrl;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getDisplayImgUrl() {
		return displayImgUrl;
	}

	public void setDisplayImgUrl(String displayImgUrl) {
		this.displayImgUrl = displayImgUrl;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public int getMonthOfBirth() {
		return monthOfBirth;
	}

	public void setMonthOfBirth(int monthOfBirth) {
		this.monthOfBirth = monthOfBirth;
	}

	public int getDayOfBirth() {
		return dayOfBirth;
	}

	public void setDayOfBirth(int dayOfBirth) {
		this.dayOfBirth = dayOfBirth;
	}

	public String getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(String birthDate) {
		this.birthDate = birthDate;
	}

	public String getCellphoneNumber() {
		return cellphoneNumber;
	}

	public void setCellphoneNumber(String cellphoneNumber) {
		this.cellphoneNumber = cellphoneNumber;
	}

	public String getWeChatNo() {
		return weChatNo;
	}

	public void setWeChatNo(String weChatNo) {
		this.weChatNo = weChatNo;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public List<TagsDTO> getTags() {
		return tags;
	}

	public void setTags(List<TagsDTO> tags) {
		this.tags = tags;
	}

	public int getEvaluationLevel() {
		return evaluationLevel;
	}

	public void setEvaluationLevel(int evaluationLevel) {
		this.evaluationLevel = evaluationLevel;
	}

	public Long getLastPurchasedDateTime() {
		return lastPurchasedDateTime;
	}

	public void setLastPurchasedDateTime(Long lastPurchasedDateTime) {
		this.lastPurchasedDateTime = lastPurchasedDateTime;
	}

	public int getTotalPurchasedTimes() {
		return totalPurchasedTimes;
	}

	public void setTotalPurchasedTimes(int totalPurchasedTimes) {
		this.totalPurchasedTimes = totalPurchasedTimes;
	}

	public double getTotalAmountOfConsumption() {
		return totalAmountOfConsumption;
	}

	public void setTotalAmountOfConsumption(double totalAmountOfConsumption) {
		this.totalAmountOfConsumption = totalAmountOfConsumption;
	}

	public String getLastLoginedRegId() {
		return lastLoginedRegId;
	}

	public void setLastLoginedRegId(String lastLoginedRegId) {
		this.lastLoginedRegId = lastLoginedRegId;
	}

	public String getLastLoginedOsType() {
		return lastLoginedOsType;
	}

	public void setLastLoginedOsType(String lastLoginedOsType) {
		this.lastLoginedOsType = lastLoginedOsType;
	}

	public String getMembershipCardNo() {
		return membershipCardNo;
	}

	public void setMembershipCardNo(String membershipCardNo) {
		this.membershipCardNo = membershipCardNo;
	}

	public int getMembershipCardLevel() {
		return membershipCardLevel;
	}

	public void setMembershipCardLevel(int membershipCardLevel) {
		this.membershipCardLevel = membershipCardLevel;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public String getMembershipCardCoverImgUrl() {
		return membershipCardCoverImgUrl;
	}

	public void setMembershipCardCoverImgUrl(String membershipCardCoverImgUrl) {
		this.membershipCardCoverImgUrl = membershipCardCoverImgUrl;
	}

	public Long getScoreInCard() {
		return scoreInCard;
	}

	public void setScoreInCard(Long scoreInCard) {
		this.scoreInCard = scoreInCard;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}

	public List<RechargeEntity> getRecharges() {
		return recharges;
	}

	public void setRecharges(List<RechargeEntity> recharges) {
		this.recharges = recharges;
	}

}
